package com.formatos;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRCsvExporterParameter;

public class CSVReport implements Formato {

	public File escribirReporte(JasperPrint jasperPrint, HttpServletResponse response)
			throws JRException, IOException {
		response.setContentType("text/plain");
		JRExporter jRExporter = new JRCsvExporter();
		jRExporter.setParameter(JRCsvExporterParameter.JASPER_PRINT,jasperPrint);
//		OutputStream output = response.getOutputStream();
//		jRExporter.setParameter(JRCsvExporterParameter.OUTPUT_STREAM, output);
//		jRExporter.exportReport();
//		output.close();
		return Util.export(jRExporter, "csv");
	}

	public Object clone() throws CloneNotSupportedException {
		return new CSVReport();
	}

}
